// 本地存储
export function setLcoalCache(key, value) {
  return window.localStorage.setItem(key, JSON.stringify(value))
}

export function getLcoalCache(key) {
  const value = window.localStorage.getItem(key)
  if (value) {
    try {
      return JSON.parse(value)
    } catch (error) {
      return ''
    }
  }
}

export function removeLcoalCache(key) {
  return window.localStorage.removeItem(key)
}

// 会话存储
export function setSessionCache(key, value) {
  return window.sessionStorage.setItem(key, JSON.stringify(value))
}
  
export function getSessionCache(key) {
  const value = window.sessionStorage.getItem(key)
  if (value) {
    try {
      return JSON.parse(value)
    } catch (error) {
      return ''
    }
  }
}
  
export function removeSessionCache(key) {
  return window.sessionStorage.removeItem(key)
}
